
<div class="forum-container">

    <ul class="thumbnails">

        <li class="thumbnail span11">

            <div class="course-threads">

                <h4>
                    ${course.name}
                    <small>${course.description}</small>
                </h4>

                <g:message code="forum.threads.label" />: <span class="badge badge-info">${course.threads.size()}</span><br />
                %{--<g:message code="forum.posts.label" />: <span class="badge badge-info"><g:if test="${course.threads}">${course.threads.sum { it.posts.size() }}</g:if><g:else>0</g:else> </span>--}%

            </div>

            <div class="course-threads" style="padding-bottom: 0px">

                <ul class="thumbnails">

                    <g:each in="${course.threads}" var="thread">

                        <g:set var="firstPost" value="${thread.posts.first()}" />

                        <li class="thumbnail">

                            <div class="thread span10" >

                                <g:if test="${session.user.role == Role.AdminUser.getValue()}">

                                    <span class="pull-right">

                                        <a class="thread-delete" itemref="${thread.id}" itemconfirm="<g:message code="default.button.delete.confirm.message" />" href="Javascript:void(0);"><g:message code="default.button.delete.label" /></a>

                                    </span>

                                </g:if>

                                <h5 class="name">
                                    ${thread.name}
                                    <small>
                                        <g:message code="forum.createdby" />:  ${firstPost.user.firstname} ${firstPost.user.lastname}
                                        <g:message code="forum.labels.on" /> <g:formatDate format="dd-MM-yyyy HH:mm" date="${thread.created}"/>
                                    </small>

                                </h5>

                                <a href="${createLink(controller: 'threads', action: 'view', params: [id: thread.id])}">${firstPost.text}?</a>

                                <div class="pull-right">

                                    <g:each var="threadTag" in="${thread.threadTags}">

                                        <a href="<g:createLink controller="tags" action="view" params="[id: threadTag.tag.id]" />">
                                            <span class="label label-info">${threadTag.tag.name}</span>
                                        </a>

                                    </g:each>

                                </div>

                            </div>

                            <div class="clearfix"></div>



                        </li>

                    </g:each>

                </ul>

            </div>

        </li>

    </ul>

    <a class="btn btn-info" role="button" href="<g:createLink controller="threads" action="add" params="[id: course.id]"/>"><g:message code="forum.thread.new" /></a>

</div>